package com.kovalko.project;

import com.kovalko.pages.SearchResultsPage;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.kovalko.pages.ComparisonPage;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * Created by 4uvak on 06.07.2014.
 */
public class CompareProducts extends BasicTest {
    @Test
    public void testOnlyDifferentButton () throws InterruptedException {
        SearchResultsPage searchResults = new SearchResultsPage(driver);
        searchResults.open();
        Assert.assertTrue(searchResults.isOpened());

        String productCode1 = searchResults.getProductCodeByProductName("LG GA-B489TGKR");
        String productCode2 = searchResults.getProductCodeByProductName("LIEBHERR CN 4003");

        ComparisonPage comparisonPage = new ComparisonPage(driver, productCode1, productCode2);
        comparisonPage.open();
        Assert.assertTrue(comparisonPage.isOpened());

        Set<String> expectedParametersThatDiffer = comparisonPage.calculateParametersThatDiffer();

        comparisonPage.clickOnlyDifferentButton();
        Set<String> actualDifference = new LinkedHashSet<>(comparisonPage.getParameters());

        Assert.assertEquals(actualDifference, expectedParametersThatDiffer);
    }


}
